package com.example.weatherpromax

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView

class dayAdapter (val futureList:List<weather_future>): RecyclerView.Adapter<dayAdapter.ViewHolder>(){

    inner class ViewHolder(view: View): RecyclerView.ViewHolder(view){
        val temp_max : TextView = view.findViewById(R.id.max_temp)
        val temp_min : TextView = view.findViewById(R.id.min_temp)
        val weather_icon_day : ImageView =view.findViewById(R.id.icon_day)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): dayAdapter.ViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_dayly_weather,parent,false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val futureList = futureList[position]
        holder.temp_max.text = futureList.max_temp
        holder.temp_min.text = futureList.low_temp
        holder.weather_icon_day.setImageResource((futureList.weatherIcon_future))
    }

    override fun getItemCount() = futureList.size


}